<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>cggbak.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CGGBAK.1"></a><a href="cggbak.f.html#CGGBAK.1">CGGBAK</a>( JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V,
     $                   LDV, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          JOB, SIDE
      INTEGER            IHI, ILO, INFO, LDV, M, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               LSCALE( * ), RSCALE( * )
      COMPLEX            V( LDV, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CGGBAK.20"></a><a href="cggbak.f.html#CGGBAK.1">CGGBAK</a> forms the right or left eigenvectors of a complex generalized
</span><span class="comment">*</span><span class="comment">  eigenvalue problem A*x = lambda*B*x, by backward transformation on
</span><span class="comment">*</span><span class="comment">  the computed eigenvectors of the balanced pair of matrices output by
</span><span class="comment">*</span><span class="comment">  <a name="CGGBAL.23"></a><a href="cggbal.f.html#CGGBAL.1">CGGBAL</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  JOB     (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies the type of backward transformation required:
</span><span class="comment">*</span><span class="comment">          = 'N':  do nothing, return immediately;
</span><span class="comment">*</span><span class="comment">          = 'P':  do backward transformation for permutation only;
</span><span class="comment">*</span><span class="comment">          = 'S':  do backward transformation for scaling only;
</span><span class="comment">*</span><span class="comment">          = 'B':  do backward transformations for both permutation and
</span><span class="comment">*</span><span class="comment">                  scaling.
</span><span class="comment">*</span><span class="comment">          JOB must be the same as the argument JOB supplied to <a name="CGGBAL.35"></a><a href="cggbal.f.html#CGGBAL.1">CGGBAL</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  SIDE    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'R':  V contains right eigenvectors;
</span><span class="comment">*</span><span class="comment">          = 'L':  V contains left eigenvectors.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of rows of the matrix V.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ILO     (input) INTEGER
</span><span class="comment">*</span><span class="comment">  IHI     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The integers ILO and IHI determined by <a name="CGGBAL.46"></a><a href="cggbal.f.html#CGGBAL.1">CGGBAL</a>.
</span><span class="comment">*</span><span class="comment">          1 &lt;= ILO &lt;= IHI &lt;= N, if N &gt; 0; ILO=1 and IHI=0, if N=0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LSCALE  (input) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          Details of the permutations and/or scaling factors applied
</span><span class="comment">*</span><span class="comment">          to the left side of A and B, as returned by <a name="CGGBAL.51"></a><a href="cggbal.f.html#CGGBAL.1">CGGBAL</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RSCALE  (input) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          Details of the permutations and/or scaling factors applied
</span><span class="comment">*</span><span class="comment">          to the right side of A and B, as returned by <a name="CGGBAL.55"></a><a href="cggbal.f.html#CGGBAL.1">CGGBAL</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  M       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of columns of the matrix V.  M &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  V       (input/output) COMPLEX array, dimension (LDV,M)
</span><span class="comment">*</span><span class="comment">          On entry, the matrix of right or left eigenvectors to be
</span><span class="comment">*</span><span class="comment">          transformed, as returned by <a name="CTGEVC.62"></a><a href="ctgevc.f.html#CTGEVC.1">CTGEVC</a>.
</span><span class="comment">*</span><span class="comment">          On exit, V is overwritten by the transformed eigenvectors.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDV     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the matrix V. LDV &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit.
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  See R.C. Ward, Balancing the generalized eigenvalue problem,
</span><span class="comment">*</span><span class="comment">                 SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            LEFTV, RIGHTV
      INTEGER            I, K
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.85"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      EXTERNAL           <a name="LSAME.86"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           CSSCAL, CSWAP, <a name="XERBLA.89"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters
</span><span class="comment">*</span><span class="comment">
</span>      RIGHTV = <a name="LSAME.98"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SIDE, <span class="string">'R'</span> )
      LEFTV = <a name="LSAME.99"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SIDE, <span class="string">'L'</span> )
<span class="comment">*</span><span class="comment">
</span>      INFO = 0
      IF( .NOT.<a name="LSAME.102"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'N'</span> ) .AND. .NOT.<a name="LSAME.102"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'P'</span> ) .AND.
     $    .NOT.<a name="LSAME.103"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'S'</span> ) .AND. .NOT.<a name="LSAME.103"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'B'</span> ) ) THEN
         INFO = -1
      ELSE IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THEN
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
         INFO = -3
      ELSE IF( ILO.LT.1 ) THEN
         INFO = -4
      ELSE IF( N.EQ.0 .AND. IHI.EQ.0 .AND. ILO.NE.1 ) THEN
         INFO = -4
      ELSE IF( N.GT.0 .AND. ( IHI.LT.ILO .OR. IHI.GT.MAX( 1, N ) ) )
     $   THEN
         INFO = -5
      ELSE IF( N.EQ.0 .AND. ILO.EQ.1 .AND. IHI.NE.0 ) THEN
         INFO = -5
      ELSE IF( M.LT.0 ) THEN
         INFO = -8
      ELSE IF( LDV.LT.MAX( 1, N ) ) THEN
         INFO = -10
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.124"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CGGBAK.124"></a><a href="cggbak.f.html#CGGBAK.1">CGGBAK</a>'</span>, -INFO )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 )
     $   RETURN
      IF( M.EQ.0 )
     $   RETURN
      IF( <a name="LSAME.134"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'N'</span> ) )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      IF( ILO.EQ.IHI )
     $   GO TO 30
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Backward balance
</span><span class="comment">*</span><span class="comment">
</span>      IF( <a name="LSAME.142"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'S'</span> ) .OR. <a name="LSAME.142"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'B'</span> ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Backward transformation on right eigenvectors
</span><span class="comment">*</span><span class="comment">
</span>         IF( RIGHTV ) THEN
            DO 10 I = ILO, IHI
               CALL CSSCAL( M, RSCALE( I ), V( I, 1 ), LDV )
   10       CONTINUE
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Backward transformation on left eigenvectors
</span><span class="comment">*</span><span class="comment">
</span>         IF( LEFTV ) THEN
            DO 20 I = ILO, IHI
               CALL CSSCAL( M, LSCALE( I ), V( I, 1 ), LDV )
   20       CONTINUE
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Backward permutation
</span><span class="comment">*</span><span class="comment">
</span>   30 CONTINUE
      IF( <a name="LSAME.164"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'P'</span> ) .OR. <a name="LSAME.164"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'B'</span> ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Backward permutation on right eigenvectors
</span><span class="comment">*</span><span class="comment">
</span>         IF( RIGHTV ) THEN
            IF( ILO.EQ.1 )
     $         GO TO 50
            DO 40 I = ILO - 1, 1, -1
               K = RSCALE( I )
               IF( K.EQ.I )
     $            GO TO 40
               CALL CSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )
   40       CONTINUE
<span class="comment">*</span><span class="comment">
</span>   50       CONTINUE
            IF( IHI.EQ.N )
     $         GO TO 70
            DO 60 I = IHI + 1, N
               K = RSCALE( I )
               IF( K.EQ.I )
     $            GO TO 60
               CALL CSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )
   60       CONTINUE
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Backward permutation on left eigenvectors
</span><span class="comment">*</span><span class="comment">
</span>   70    CONTINUE
         IF( LEFTV ) THEN
            IF( ILO.EQ.1 )
     $         GO TO 90
            DO 80 I = ILO - 1, 1, -1
               K = LSCALE( I )
               IF( K.EQ.I )
     $            GO TO 80
               CALL CSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )
   80       CONTINUE
<span class="comment">*</span><span class="comment">
</span>   90       CONTINUE
            IF( IHI.EQ.N )
     $         GO TO 110
            DO 100 I = IHI + 1, N
               K = LSCALE( I )
               IF( K.EQ.I )
     $            GO TO 100
               CALL CSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )
  100       CONTINUE
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>  110 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CGGBAK.218"></a><a href="cggbak.f.html#CGGBAK.1">CGGBAK</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
